package com.zhonghui.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.mes.domain.vo.MesMaterialInspectorVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.domain.AjaxResult;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.mes.domain.MesMaterialInspector;
import com.zhonghui.mes.service.IMesMaterialInspectorService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 制造执行MES-质量管理-来料检验
Controller
 * 
 * @author zhonghui
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/mes/inspector")
public class MesMaterialInspectorController extends BaseController
{
    @Autowired
    private IMesMaterialInspectorService mesMaterialInspectorService;

    /**
     * 查询制造执行MES-质量管理-来料检验列表
     */
    @PreAuthorize("@ss.hasPermi('mes:inspector:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesMaterialInspectorVo mesMaterialInspector)
    {
        startPage();
        List<MesMaterialInspectorVo> list = mesMaterialInspectorService.selectMesMaterialInspectorList(mesMaterialInspector);
        return getDataTable(list);
    }

    /**
     * 导出制造执行MES-质量管理-来料检验列表
     */
    @PreAuthorize("@ss.hasPermi('mes:inspector:export')")
    @Log(title = "制造执行MES-质量管理-来料检验 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesMaterialInspectorVo mesMaterialInspector)
    {
        List<MesMaterialInspectorVo> list = mesMaterialInspectorService.selectMesMaterialInspectorList(mesMaterialInspector);
        ExcelUtil<MesMaterialInspectorVo> util = new ExcelUtil<MesMaterialInspectorVo>(MesMaterialInspectorVo.class);
        util.exportExcel(response, list, "制造执行MES-质量管理-来料检验 数据");
    }

    /**
     * 获取制造执行MES-质量管理-来料检验
详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:inspector:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesMaterialInspectorService.selectMesMaterialInspectorById(id));
    }

    /**
     * 新增制造执行MES-质量管理-来料检验

     */
    @PreAuthorize("@ss.hasPermi('mes:inspector:add')")
    @Log(title = "制造执行MES-质量管理-来料检验 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesMaterialInspector mesMaterialInspector)
    {
        return toAjax(mesMaterialInspectorService.insertMesMaterialInspector(mesMaterialInspector));
    }

    /**
     * 修改制造执行MES-质量管理-来料检验

     */
    @PreAuthorize("@ss.hasPermi('mes:inspector:edit')")
    @Log(title = "制造执行MES-质量管理-来料检验 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesMaterialInspector mesMaterialInspector)
    {
        return toAjax(mesMaterialInspectorService.updateMesMaterialInspector(mesMaterialInspector));
    }

    /**
     * 删除制造执行MES-质量管理-来料检验

     */
    @PreAuthorize("@ss.hasPermi('mes:inspector:remove')")
    @Log(title = "制造执行MES-质量管理-来料检验 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesMaterialInspectorService.deleteMesMaterialInspectorByIds(ids));
    }
}
